﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestService.Host
{
    public class ServerManager
    {
        private static ServerManager _instance = null;
        private static object _lockObj = new object();

        private ServerManager() { }

        public static ServerManager Instance
        {
            get
            {
                if (_instance == null)
                    lock (_lockObj)
                        if (_instance == null)
                            _instance = new ServerManager();
                return _instance;
            }
        }

        private static bool _isStop = false;
        private Queue _objs = new Queue();

        // 停止监听服务
        public void KillAll()
        {
            //_taobaoListener.Stop();
        }

        // 设置停止Server线程标识
        public static void SetStop()
        {
            _isStop = true;
        }

        // 根据标识停止线程
        public static bool IsStop()
        {
            return _isStop;
        }

        // 向队列中加如对象
        public void QueueOpcode(object args)
        {
            Queue q = Queue.Synchronized(_objs);
            q.Enqueue(args);
        }

        public void Update(int diff)
        {
            Queue q = Queue.Synchronized(_objs);

            
        }
    }
}
